package cn.iocoder.yudao.module.erp.controller.admin.common.unique;

import cn.iocoder.yudao.framework.common.pojo.CommonResult;
import cn.iocoder.yudao.module.erp.controller.admin.common.unique.vo.UniqueNoReqVO;
import cn.iocoder.yudao.module.erp.controller.admin.strategy.uniqueNo.UniqueFactory;
import io.swagger.v3.oas.annotations.tags.Tag;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import javax.validation.Valid;

import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success;

/**
 * @author Max-u-19
 */
@Tag(name = "管理后台 - ERP 通用方法接口")
@RestController
@RequestMapping("/erp/common")
@Validated
public class UniqueNoController {
    @Resource
    private UniqueFactory uniqueFactory;
    @PostMapping("/unique-no")
    public CommonResult<Boolean> checkNoUnique(@Valid @RequestBody UniqueNoReqVO uniqueNoReqVO) {
        return success(uniqueFactory.handle(uniqueNoReqVO.getNo(), uniqueNoReqVO.getBeanName()));
    }

}
